﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_LearnerOnLineStudy : DLL.MyAdminPage
{
	private DLL.TrainingCourseware.Component clsTrainingCoursewareComp;

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
			BindGridView();
		}
	}

	protected override void OnInit(EventArgs e)
	{
		clsTrainingCoursewareComp = new DLL.TrainingCourseware.Component(Page);

		base.OnInit(e);

		Grv.RowCommand += new GridViewCommandEventHandler(Grv_RowCommand);
	}

	void Grv_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		if (e.CommandName == "MyStudy")
		{
			ShowNewStudy(Convert.ToInt32(e.CommandArgument));
		}
	}

	private void BindGridView()
	{
		Grv.DataSource = clsTrainingCoursewareComp.QueryOneLearnerTrainingCourseware();
		Grv.DataKeyNames = new string[] { "ID" };
		Grv.DataBind();
	}

	/// <summary>
	/// 弹出播放课件的网页
	/// </summary>
	private void ShowNewStudy(int nTrainingCourewareID)
	{
		Literal litMessage = new Literal();

		litMessage.Text = "<Script Language='JavaScript'>window.open ('Study.aspx?TrainingCoursewareID=" + nTrainingCourewareID.ToString() + "', 'newwindow', 'height=600, width=800, top=100, left=100, toolbar=no, menubar=no, scrollbars=yes,resizable=yes,location=no, status=no');</script>";
		Page.Controls.Add(litMessage);
	}
}